import japa.parser.JavaParser;
import japa.parser.ast.CompilationUnit;
import japa.parser.ast.Node;
import japa.parser.ast.body.ClassOrInterfaceDeclaration;
import japa.parser.ast.body.MethodDeclaration;
import japa.parser.ast.type.ClassOrInterfaceType;
import japa.parser.ast.visitor.VoidVisitorAdapter;

import java.io.File;
import java.io.FileInputStream;

import javax.swing.JFileChooser;
import javax.swing.JFrame;

public class NumberOfLinesInMethods {

	public NumberOfLinesInMethods(CompilationUnit cu) {

		// System.out.println("Number of lines " +cu.getEndLine());

		// visit and print the methods names
		MethodVisitor mv = new MethodVisitor();
		mv.visit(cu, null);


	}

	/**
	 * Simple visitor implementation for visiting MethodDeclaration nodes.
	 */
	private static class MethodVisitor extends VoidVisitorAdapter {
		int count = 0;

		@Override
		public void visit(MethodDeclaration n, Object arg) {
			// here you can access the attributes of the method.
			// this method will be called for all methods in this
			// CompilationUnit, including inner class methods
			count++;
			System.out.println('\t' + n.getName());
			if (n.getEndLine() < 22) {
				System.out.println("The number of lines in this method are "
						+ n.getEndLine());

			} else {
				System.out.println("The number of lines in this method are "
						+ n.getEndLine());
				// System.out.println("There are two many lines of code in this method");
			}

			System.out.println('\n');
		}

	}
}